package com.example.spring.aop.tx.anno.dao.impl;

import com.example.spring.aop.tx.anno.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;


@Repository
public class AccountDaoImpl implements AccountDao {

    @Autowired
    private JdbcTemplate jdbcT;

    @Override
    public void out(String outer, int money) {
        String sql = "update accout set money = money - ? where username = ?";
        jdbcT.update(sql, money, outer);
    }

    @Override
    public void in(String inner, int money) {
        String sql = "update accout set money = money + ? where username = ?";
        jdbcT.update(sql, money, inner);
    }
}
